/**  

* @Title: LoginAction.java 

* @Package com.gxbadge.action 

* @Description: TODO(用一句话描述该文件做什么) 

* @author CST

* @version V1.0  

*/ 

package com.gxbadge.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.gxbadge.action.base.BaseAction;
import com.gxbadge.model.Administrator;
import com.gxbadge.model.Category;
import com.gxbadge.model.Language;
import com.gxbadge.model.Navigation;
import com.gxbadge.model.Operator;
import com.gxbadge.util.MD5;
import com.opensymphony.xwork2.ActionContext;

public class OperatorAction extends BaseAction {
	
	private Navigation nav;
	private Operator oper;
	private List<Operator> operList;
	public Navigation getNav() {
		return nav;
	}

	public void setNav(Navigation nav) {
		this.nav = nav;
	}

	public Operator getOper() {
		return oper;
	}

	public void setOper(Operator oper) {
		this.oper = oper;
	}

	public List<Operator> getOperList() {
		return operList;
	}

	public void setOperList(List<Operator> operList) {
		this.operList = operList;
	}

	private String paramNavId;
	
	public String getParamNavId() {
		return paramNavId;
	}

	public void setParamNavId(String paramNavId) {
		this.paramNavId = paramNavId;
	}

	public String find_operListByNavId() throws Exception{
		
		if(this.getOperList()!=null){
			this.setOperList(null);
		}
		if(this.getParamNavId()!=null){
			
			int navId = Integer.parseInt(this.getParamNavId());
			Navigation nav = adminManager.findNavByNavId(navId);
			if(nav!=null){
				List<Operator> operList = adminManager.findOperListByNav(nav);
				if(operList!=null&&operList.size()>=1){
					this.setOperList(operList);
				}
			}
			this.setParamNavId(null);
		}

		return "operListByNavId_find_success";
	}
	public String insert_oper() throws Exception{
		
		if(this.getOper()!=null){
			this.setOper(null);
		}
		if(this.getNav()!=null&&this.getNav().getNavId()!=null){
			Navigation nav = adminManager.findNavByNavId(this.getNav().getNavId());
			if(nav!=null){
				
				this.setNav(nav);

			}
		}
		return "oper_insert_success";
	}
	public String add_oper() throws Exception{
		
		
		if(this.getNav()!=null){
			
			this.getOper().setNav(nav);

		}
		adminManager.add_oper(this.getOper());
		
		
		return "oper_add_success";
		
	}
	public String del_oper() throws Exception{
		
		if(this.getOper()!=null&&this.getOper().getOperId()!=null){
			
			Operator oper = adminManager.findOperByOperId(this.getOper().getOperId());
			if(oper!=null){
				adminManager.del_oper(oper);
			}
		}
		
		return "oper_del_success";
	}
	
	public String upload_oper() throws Exception{
		
		if(this.getOper()!=null&&this.getOper().getOperId()!=null){
			
			Operator oper = adminManager.findOperByOperId(this.getOper().getOperId());
			if(oper!=null){
				this.setOper(oper);
			}
		}
		return "oper_upload_succcess";
	}
	public String modify_oper() throws Exception{
		
		adminManager.modify_oper(this.getOper());
		this.setOper(null);
		return "oper_modify_success";
	}
}
